setwd("~/Application1")
source("SimulationCode/simulationSummary.R")

mach_summary <- simulationSummary("SimulationOutput/Mach.R")
narc_summary <- simulationSummary("SimulationOutput/Narc.R")
emp_summary <- simulationSummary("SimulationOutput/Emp.R")
syst_summary <- simulationSummary("SimulationOutput/Syst.R")

all_output <- list(narc_summary, mach_summary, emp_summary, syst_summary)
all_lengths <- c(16, 5, 15, 25)


## % decrease using adaptive/fixed over random is: (random - adaptive or fixed) / random
## Then difference in improvement is (adaptive improvement - fixed improvement)
outMat<-matrix(NA, nrow=8, ncol=4)
colnames(outMat) <- c("NPI", "MACH", "EMP", "SYST")
rownames(outMat) <- c("battery length", "random rmse", "adaptive rmse", "% impr over random",
                      "random rmse", "adaptive rmse", "% impr over random", "diff in impr")
for(i in 1:4){
    len <- all_lengths[i]
    summ <- all_output[[i]]
    
    a <- summ[len,"rmse","random"]
    b <- summ[len,"rmse","fixed"]
    c <- (summ[len,"rmse","random"] - summ[len,"rmse","fixed"])/summ[len,"rmse","random"]
    
    d <- summ[len,"rmse","random"]
    e <- summ[len,"rmse","dynamic"]
    f <- (summ[len,"rmse","random"] - summ[len,"rmse","dynamic"])/summ[len,"rmse","random"]
    
    g <- (f-c)
    
    outMat[,i]<-c(len, d, e, f*100, a, b, c*100, g*100)
}

#pvalues for the Wilcoxon Rank-Sm test
wilcox_pval("SimulationOutput/Mach.R")
wilcox_pval("SimulationOutput/Narc.R")
wilcox_pval("SimulationOutput/Emp.R")
wilcox_pval("SimulationOutput/Syst.R")

